<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>机器人聊天室 </title>
<link rel="shortcut icon" href="favicon.png">
<link rel="icon" href="favicon.png" type="image/x-icon">
<link type="text/css" rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>

<body>
<div class="chatbox">
  <div class="chat_top fn-clear">
    <div class="logo"><img src="images/logo.png" width="190" height="60"  alt=""/></div>
    <div class="uinfo fn-clear">
     
    </div>
  </div>
  <div class="chat_message fn-clear">
    <div class="chat_left">
      <div class="message_box" id="message_box"> </div>
      
      <div class="write_box">
        <textarea id="message" name="message" class="write_area" placeholder="说点啥吧..."></textarea>
        <div class="facebox fn-clear">
          <div class="expression"></div>
          <button name="" class="sub_but">提 交</button>
        </div>
      </div>
    </div>
   
  </div>
</div>
<script src="js/RobotAPI.js" type="text/javascript" charset="utf-8"></script>
<script src="js/View.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function(){
	
	//实例化对象
	var talkView = new TalkView();
	var robotAPI =new RobotAPI();
	
	talkView.robotSendMessage("请问你想知道什么，智创机器人为您服务");
	
	//发送按钮绑定点击事件
	$('.sub_but').click(function(event){
			var userMsg = $("#message").val();
	    talkView.userSendMessage(userMsg);
	    RobotAnswer(userMsg);
	    
	   
	});
	//机器人回答问题
	function RobotAnswer(msg){
			robotAPI.robotTalk(msg,function(res){
				 talkView.robotSendMessage(res);
			});
		}

});
//	/*按下按钮或键盘按键*/
//	$("#message").keydown(function(event){
//		var e = window.event || event;
//      var k = e.keyCode || e.which || e.charCode;
//		//按下ctrl+enter发送消息
//		if((event.ctrlKey && (k == 13 || k == 10) )){
//		
//		}
</script>
</body>
</html>
